package com.dimples.dd.system.convert;

import com.dimples.dd.common.model.Option;
import com.dimples.dd.common.pojo.PageResult;
import com.dimples.dd.system.model.entity.SystemDataSourceConfigDO;
import com.dimples.dd.system.model.form.DataSourceConfigForm;
import com.dimples.dd.system.model.vo.DataSourceConfigPageVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/10/19
 */
@Mapper(componentModel = "spring")
public interface DataSourceConfigConvert {

    SystemDataSourceConfigDO from2Entity(DataSourceConfigForm dataSourceConfigForm);

    DataSourceConfigForm entity2Form(SystemDataSourceConfigDO dataSourceConfigDO);

    List<Option<String>> entities2Options(List<SystemDataSourceConfigDO> configDOList);

    @Mappings({
            @Mapping(target = "label", source = "name"),
            @Mapping(target = "value", source = "code")
    })
    Option<String> entity2Option(SystemDataSourceConfigDO configDO);

    PageResult<DataSourceConfigPageVO> entity2PageVo(PageResult<SystemDataSourceConfigDO> configDOPageResult);

    DataSourceConfigPageVO entity2Vo(SystemDataSourceConfigDO configDO);
}
